package com.xuecheng.content.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xuecheng.content.model.po.TeachplanMedia;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.DeleteMapping;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author itcast
 */
public interface TeachplanMediaMapper extends BaseMapper<TeachplanMedia> {

    /**
     * 根据课程计划id删除课程计划媒资信息
     * @param id
     */
    @Delete("delete from teachplan_media where teachplan_id = #{teachplanId} and course_id = #{courseId}")
    void deleteByTeachplanId(@Param("teachplanId") Long teachplanId, @Param("courseId") Long courseId);

    /**
     * 根据计划id查询计划媒资信息
     * @param teachplanId
     * @return
     */
    @Select("select * from teachplan_media where teachplan_id = #{teachplanId}")
    TeachplanMedia selectByTeachplanId(Long teachplanId);

    /**
     * 根据计划id删除媒资信息
     * @param teachplanId
     * @param mediaId
     */
    @Delete("delete from teachplan_media where teachplan_id = #{teachplanId} and media_id = #{mediaId}")
    void deleteMedia(@Param("teachplanId") Long teachplanId, @Param("mediaId")String mediaId);
}
